#pragma once
#include"HashTable.h"
namespace bit
{
	template<class K, class V>
	class UnorderedMap
	{
	public:
		struct KeyofT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
		typedef typename hash_bucket::Hash_Table<K, pair<K, V>, KeyofT>::iterator iterator;
		typedef typename hash_bucket::Hash_Table<K, pair<K, V>, KeyofT>::const_iterator const_iterator;
		iterator begin()
		{
			return  map.begin();
		}
		iterator end()
		{
			return map.end();
		}
		const_iterator begin()const
		{
			return map.begin();
		}
		const_iterator end()const
		{
			return map.end();
		}
		pair<iterator, bool> insert(const pair<K,V>& _kv)
		{
			return map.Insert(_kv);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> it = map.Insert(make_pair(key, V()));
			return it.first->second;
		}
	private:
		hash_bucket::Hash_Table<K, pair<K, V>, KeyofT> map;
	};
}